package com.sqlcheck.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sqlcheck.entity.CompatibilityRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CompatibilityRuleRepository extends BaseMapper<CompatibilityRule> {

    @Select("SELECT * FROM compatibility_rules " +
            "WHERE is_active = 1 AND deleted = 0 " +
            "AND source_db_type = #{source} AND target_db_type = #{target}")
    List<CompatibilityRule> findActiveBySourceAndTarget(@Param("source") CompatibilityRule.DbType source,
            @Param("target") CompatibilityRule.DbType target);
    
    @Select("SELECT * FROM compatibility_rules " +
            "WHERE rule_id = #{ruleId} AND deleted = 0 LIMIT 1")
    CompatibilityRule findByRuleId(@Param("ruleId") String ruleId);
}
